home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / rexx / imc / rexx-imc.5 / const.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-06-25  |  14.1 KB  |  352 lines

  1. /* The constants and data types of REXX/imc      (C) Ian Collier 1992 */
  2.  
  3. #define VER "beta-1.5"
  4. #define LEVEL "4.00"  /* Language level supported */
  5.  
  6. #include<sys/types.h>
  7. #include<sys/time.h>
  8. #include<stdio.h>
  9. #define four       (sizeof(int))
  10. #define align(x)   (((x)+3)&~3)
  11. #define toalign(x) (((~(x))+1)&3)
  12.  
  13. #define rxmathname "rxmathfn"   /* The basenames of the two REXX auxiliary */
  14. #define rxquename  "rxque"      /* files  */
  15.  
  16. #define filetype   ".exec"      /* Default file extension */
  17.  
  18. #define maxopstack 30    /* Maximum number of pending operations in an expr */
  19. #define maxvarname 250   /* Maximum length of a variable name or label */
  20. #define maxargs 30       /* Maximum number of arguments in function call */
  21. #define maxextension 32  /* Maximum length of a file extension */
  22. #define maxexp 999999999 /* maximum exponent of a number (must fit into int) */
  23. #define maxdigits 10000  /* maximum allowable setting for NUMERIC DIGITS */
  24. #define traceindent 1    /* Spaces per indentation level in traceback */
  25. #define STDIN 0          /* = fileno(stdin) */
  26.  
  27. #define cnull (char *)0  /* Various null pointers ... */
  28. #define inull (int *)0
  29.  
  30. #define Isyntax   0      /* Integers associated with the SIGNAL ON traps */
  31. #define Ierror    1
  32. #define Ihalt     2
  33. #define Inovalue  3
  34. #define Ifailure  4
  35. #define Inotready 5
  36. #define Imax      6
  37.  
  38. #define Tclauses    1    /* The bit values for the various TRACE facilities */
  39. #define Tlabels     2
  40. #define Tresults    4
  41. #define Tintermed   8
  42. #define Tcommands  16
  43. #define Terrors    32
  44. #define Tfailures  64
  45. #define Tinteract 128
  46.  
  47. #define Einit      -1   /* Initialisation error */
  48. #define Ehalt       4   /* Program interrupted */
  49. #define Emem        5   /* Machine storage exhausted */
  50. #define Elcomm      6   /* Unmatched '/*' */
  51. #define Equote      6   /* Unmatched quote */
  52. #define Enowhen     7   /* Expected WHEN */
  53. #define Eselect     7   /* Expected OTHERWISE */
  54. #define Ethen       8   /* Unexpected THEN */
  55. #define Ewhen       9   /* Unexpected WHEN */
  56. #define Eend       10   /* Unexpected or unmatched END */
  57. #define Echar      13   /* Invalid character in program */
  58. #define Enoend     14   /* Incomplete DO/SELECT/IF */
  59. #define Eprogend   14
  60. #define Ebin       15   /* Invalid binary constant */
  61. #define Ehex       15   /* Invalid hexadecimal constant */
  62. #define Elabel     16   /* Label not found */
  63. #define Eprocedure 17   /* Unexpected PROCEDURE */
  64. #define Enothen    18   /* Expected THEN */
  65. #define Enostring  19   /* String or symbol expected */
  66. #define Enosymbol  20   /* Symbol expected */
  67. #define Exend      21   /* Invalid data on end of clause */
  68. #define Etrace     24   /* Invalid TRACE request */
  69. #define Eform      25   /* Invalid subkeyword found */
  70. #define Etrap      25
  71. #define Enonint    26   /* Invalid whole number */
  72. #define Erange     26
  73. #define Exdo       27   /* Invalid DO syntax */
  74. #define Eleave     28   /* Invalid LEAVE or ITERATE */
  75. #define Elong      30   /* Symbol too long */
  76. #define Ename      31   /* Name starts with number or '.' */
  77. #define Ebadexpr   35   /* Invalid expression */
  78. #define Eassign    35
  79. #define Elpar      36   /* Unmatched '(' */
  80. #define Ecomma     37   /* Unexpected comma */
  81. #define Erpar      37   /* Unexpected ')' */
  82. #define Eparse     38   /* Invalid template */
  83. #define Eopstk     39   /* Evaluation stack overflow */
  84. #define Eargs      40
  85. #define Ecall      40   /* Incorrect call to routine */
  86. #define Eformat    40
  87. #define Enoarg     40
  88. #define Enum       41   /* Bad arithmetic conversion */
  89. #define Edivide    42
  90. #define Eoflow     42   /* Arithmetic overflow or underflow */
  91. #define Eundef     43   /* Routine not found */
  92. #define Enoresult  44   /* Function did not return data */
  93. #define Esys       48   /* Failure in system service */
  94. #define Elost      49   /* Implementation error */
  95. #define Eincalled  50   /* Error in called routine */
  96. #define Enovalue   80   /* No-value error */
  97. #define Eexist     81   /* Use of an un-implemented feature! */
  98. #define Esyntax    82   /* Syntax error */
  99. #define Elabeldot  83   /* Label ends with '.' */
  100. #define Emanyargs  84   /* Too many arguments (> 30) */
  101. #define Eerror     85   /* command returned error */
  102. #define Efailure   86   /* command returned failure */
  103. #define Enotready  87   /* I/O operation raised "notready" error */
  104. #define Ercomm     88   /* Unexpected '* /' */
  105. #define Eeof       99   /* End of file */
  106. #define Eerrno    100   /* errortext(rc+Eerrno) gives the IO error for rc */
  107. #define Ebounds   200   /* File position was out of bounds */
  108. #define Eseek     201   /* Reposition attempted on transient stream */
  109. #define Eaccess   202   /* Write attempted on a read-only stream */
  110.  
  111. #define numwords 50     /* How many tokens are below */
  112. #define Command -102    /* "Command" tokens are strictly less than this */
  113.  
  114. #define SAY       -128  /* The various tokens */
  115. #define SAYN      -127  /*  - in the same order as in words[] */
  116. #define DO        -126
  117. #define END       -125
  118. #define IF        -124
  119. #define ELSE      -123
  120. #define SELECT    -122
  121. #define WHEN      -121
  122. #define OPTIONS   -120
  123. #define PARSE     -119
  124. #define PUSH      -118
  125. #define QUEUE     -117
  126. #define EXIT      -116
  127. #define RETURN    -115
  128. #define CALL      -114
  129. #define SIGNAL    -113
  130. #define ITERATE   -112
  131. #define LEAVE     -111
  132. #define INTERPRET -110
  133. #define TRACE     -109
  134. #define OTHERWISE -108
  135. #define NOP       -107
  136. #define PROCEDURE -106
  137. #define ADDRESS   -105
  138. #define NUMERIC   -104
  139. #define DROP      -103
  140. #define THEN      -102
  141. #define PULL      -101
  142. #define ARG       -100
  143. #define SOURCE    -99
  144. #define VAR       -98
  145. #define VERSION   -97
  146. #define LINEIN    -96
  147. #define VALUE     -95
  148. #define WITH      -94
  149. #define UPPER     -93
  150. #define TO        -92
  151. #define BY        -91
  152. #define FOR       -90
  153. #define FOREVER   -89
  154. #define WHILE     -88
  155. #define UNTIL     -87
  156. #define ON        -86
  157. #define OFF       -85
  158. #define DIGITS    -84
  159. #define FUZZ      -83
  160. #define FORM      -82
  161. #define EXPOSE    -81
  162. #define HIDE      -80
  163. #define NAME      -79
  164.  
  165. #define SYMBOL    -16 /*240*/            /* lowest symbol number */
  166. #define CONCAT    -15 /*241*/ /* ||  */  /* The various symbolic tokens */
  167. #define LXOR      -14 /*242*/ /* &&  */
  168. #define EQU       -13 /*243*/ /* ==  */
  169. #define LEQ       -12 /*244*/ /* <=  */
  170. #define GEQ       -11 /*245*/ /* >=  */
  171. #define NEQ       -10 /*246*/ /* \=  */
  172. #define NNEQ      -9  /*247*/ /* \== */
  173. #define MOD       -8  /*248*/ /* //  */
  174. #define LESS      -7  /*249*/ /* <<  */
  175. #define GRTR      -6  /*250*/ /* >>  */
  176. #define LLEQ      -5  /*251*/ /* <<= */
  177. #define GGEQ      -4  /*252*/ /* >>= */
  178. #define POWER     -3  /*253*/ /* **  */
  179.  
  180. #define Cconcat   0x7c7c    /* || */     /* ASCII values of these operators */
  181. #define Cxor      0x2626    /* && */
  182. #define Cequ      0x3d3d    /* == */
  183. #define Cleq1     0x3c3d    /* <= */
  184. #define Cleq2     0x5c3e    /* \> */
  185. #define Cgeq1     0x3e3d    /* >= */
  186. #define Cgeq2     0x5c3c    /* \< */
  187. #define Cneq1     0x5c3d    /* \= */
  188. #define Cneq2     0x3c3e    /* <> */
  189. #define Cneq3     0x3e3c    /* >< */
  190. #define Cnneq     0x5c3d3d  /* \== */
  191. #define Cmod      0x2f2f    /* // */
  192. #define Cless     0x3c3c    /* << */
  193. #define Cgrtr     0x3e3e    /* >> */
  194. #define Clleq1    0x3c3c3d  /* <<= */
  195. #define Clleq2    0x5c3e3e  /* \>> */
  196. #define Cggeq1    0x3e3e3d  /* >>= */
  197. #define Cggeq2    0x5c3c3c  /* \<< */
  198. #define Cpower    0x2a2a    /* ** */
  199.  
  200. #define OPpower   0 /* **        */ /* The various operator numbers (used   */
  201. #define OPmul     1 /* *         */ /* by scanning() and related functions) */
  202. #define OPdiv     2 /* /         */
  203. #define OPadd     3 /* + (binary)*/
  204. #define OPsub     4 /* - (binary)*/
  205. #define OPspc     5 /* space     */
  206. #define OPcat     6 /* ||        */
  207. #define OPequ     7 /* =         */
  208. #define OPeequ    8 /* ==        */
  209. #define OPless    9 /* <         */
  210. #define OPleq    10 /* <=        */
  211. #define OPgrtr   11 /* >         */
  212. #define OPgeq    12 /* >=        */
  213. #define OPneq    13 /* \=        */
  214. #define OPand    14 /* &         */
  215. #define OPxor    15 /* &&        */
  216. #define OPor     16 /* |         */
  217. #define OPidiv   17 /* %         */
  218. #define OPmod    18 /* //        */
  219. #define OPnneq   19 /* \==       */
  220. #define OPlless  20 /* <<        */
  221. #define OPggrtr  21 /* >>        */
  222. #define OPlleq   22 /* <<=       */
  223. #define OPggeq   23 /* >>=       */
  224. #define OPneg    24 /* - (unary) */
  225. #define OPplus   25 /* + (unary) */
  226. #define OPnot    26 /* \         */
  227.  
  228. typedef struct _program {   /* Structure for the preprocessed program */
  229.    int num;                 /* Line number in source (for traceback) */
  230.    char *source;            /* Start of this statement within the source */
  231.    char *sourcend;          /* End of same */
  232.    int related;             /* A related statement number (if any) */
  233.    char *line;              /* The program line to be interpreted */
  234. } program;
  235.    
  236. struct procstack {  /* A program stack entry for an external procedure call */
  237.    int stmt;        /* Statement number of call instruction */
  238.    char *csp;       /* Old calculator stack */
  239.    int ecsp;        /* Old calculator stack end */
  240.    int csl;         /* Old calculator stack length */
  241.    char trc;        /* Old trace flag */
  242.    char tim;        /* Old timestamp flag */
  243.    char form;       /* Old NUMERIC FORM */
  244.                     /* Some padding (one byte, probably) */
  245.    int digits;      /* Old NUMERIC DIGITS */
  246.    int fuzz;        /* Old NUMERIC FUZZ */
  247.    long mic;        /* Old timestamp microseconds */
  248.    long sec;        /* Old timestamp seconds */
  249.    program *prg;    /* Old tokenised program */
  250.    int stmts;       /* Old number of statements */
  251.    int lines;       /* Old number of program lines */
  252.    char **src;      /* Old source */
  253.    char *lab;       /* Old labels */
  254.    int lev;         /* Old pstack level */
  255.    int len;         /* Length of this stack entry */
  256.    int type;        /* Type = 13 for external procedure call */
  257. };
  258.  
  259. struct procstack2 { /* A program stack entry for a procedure call */
  260.    int stmt;        /* Statement number of call instruction */
  261.    char *csp;       /* Old calculator stack */
  262.    int ecsp;        /* Old calculator stack end */
  263.    int csl;         /* Old calculator stack length */
  264.    char trc;        /* Old trace flag */
  265.    char tim;        /* Old timestamp flag */
  266.    char form;       /* Old NUMERIC FORM */
  267.                     /* Some padding (one byte, probably) */
  268.    int digits;      /* Old NUMERIC DIGITS */
  269.    int fuzz;        /* Old NUMERIC FUZZ */
  270.    long mic;        /* Old timestamp microseconds */
  271.    long sec;        /* Old timestamp seconds */
  272.    program *prg;    /* The current interpreted string or the current program */
  273.    int stmts;       /* Number of statements in the above */
  274.    int len;         /* Length of this stack entry */
  275.    int type;        /* Type = 11 for internal procedure call;  */
  276. };                  /*        12 after a PROCEDURE instruction */
  277.  
  278. struct minstack {   /* A minimum program stack entry */
  279.    int stmt;        /* Statement where block started */
  280.    char *pos;       /* Pointer to statement (used to find the WHILE or UNTIL)*/
  281.    int len;         /* Length of this stack entry */
  282.    int type;        /* Type =  0 for DO;  */
  283. };                  /*         8 for DO WHILE/FOREVER */
  284.                     /*        10 for DO with control variable */
  285.             /*         2 for SELECT */
  286.  
  287. struct forstack {   /* A program stack entry for the "DO count" instruction */
  288.    int stmt;        /* Statement number of DO instruction */
  289.    char *pos;       /* Pointer to statement (used to find the WHILE or UNTIL)*/
  290.    int fornum;      /* Loop counter */
  291.    int len;         /* Length of this stack entry */
  292.    int type;        /* Type = 15 for a "DO count" instruction */
  293. };
  294.  
  295. struct interpstack {/* A program stack entry for the INTERPRET instruction */
  296.    int stmt;        /* Statement number of INTERPRET instruction */
  297.    program *prg;    /* Old tokenised program */
  298.    int stmts;       /* Old number of statements */
  299.    int len;         /* Length of this stack entry */
  300.    int type;        /* Type = 14 for an INTERPRET instruction */
  301. };
  302.  
  303. struct interactstack {/* A program stack entry for interactive instructions */
  304.                       /* NB always followed by an interpstack entry */
  305.    int stmt;        /* Statement number of the interruption */
  306.    char *csp;       /* Old calculator stack */
  307.    int ecs;         /* Old calculator stack end pointer */
  308.    int csl;         /* Old calculator stack length */
  309.    int len;         /* Length of this stack entry */
  310.    int type;        /* Type = 16 for interactive instructions */
  311. };
  312.  
  313. struct errorstack { /* A program stack entry for saving a traceback line */
  314.    int stmt;        /* Statement number of the error */
  315.    program *prg;    /* Program where the error occurred */
  316.    int stmts;       /* Number of statements in this program */
  317.    int len;         /* Length of this stack entry */
  318.    int type;        /* Type = 20 for saved traceback line */
  319. };
  320.  
  321. struct fileinfo {   /* Structure containing information about an open file */
  322.    FILE *fp;        /* The stream pointer */
  323.    char wr;         /* Whether writing is allowed */
  324.    char lastwr;     /* Whether the last operation was a write */
  325.    char persist;    /* Whether the file is persistent (i.e. a regular file) */
  326.    long rdpos;      /* The read character position (0-based) */
  327.    int rdline;      /* The read line position, if known (1-based) */
  328.    int rdchars;     /* Whether an incomplete line has been read */
  329.    long wrpos;      /* The write character position (0-based) */
  330.    int wrline;      /* The write line position, if known (1-based) */
  331.    int wrchars;     /* Whether an incomplete line has been written */
  332.    int errno;       /* Error status for stream('d') */
  333. };
  334.    
  335. typedef struct _hashent { /* Structure containing hash table entry */
  336.    int next;        /* Length of the whole item */
  337.    int less;        /* Pointer to left child */
  338.    int grtr;        /* Pointer to right child */
  339.    void *value;     /* Pointer to value */
  340. } hashent;
  341.  
  342. typedef struct _funcinfo { /* Structure containing info about a function */
  343.    void *dlhandle;         /* Handle from dlopen(), if this is the "main" fn */
  344.    int (*dlfunc)();        /* Address of the function */
  345. } funcinfo;
  346.  
  347. typedef struct _dictionary {/* Structure containing a list of REXX functions */
  348.    char *name;              /* REXX name of function */
  349.    int (*function)();       /* Address of function */
  350. } dictionary;
  351.  
  352.